<template>
<div class="ui  withdraw-auditfc ">
    <div class="ui grid ">
        <div :class="{eight:option.data.operateShow,'ui big loader':loaderShow,'wide column ':true}">
            <table class="ui celled table" v-show='!loaderShow'>
                <tbody>
                    <tr v-for="item in withdrawList">
                        <td><span class="ui small header">{{item.name}}</span></td>
                        <td v-if="item.map">{{item.map[item.value]}}</td>
                        <td v-else>{{item.value}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div v-if='option.data.operateShow' class="eight wide column" v-show='!loaderShow'>
            <h3 class="ui header">操作</h3>
            <h4 class="ui header">提现状态</h4>
            <fselect fname='status' @selectValsChange='selectValsChange' :val="withdrawVal" :data="withdrawArray" placeholder="请选择状态"></fselect>

            <div class="ui form marginTop10">
                <div class="field" v-show='withdrawVal==2'>
                    <label>第三方交易流水号</label>
                    <input type="tel" v-model='serialNumber'>
                </div>
                <div class="field" v-show='withdrawVal==2'>
                    <label>第三方备注信息</label>
                    <textarea v-model='returnRemark'></textarea>
                </div>
                <div class="field">
                    <label>备注</label>
                    <textarea v-model="withdrawMsg"></textarea>
                </div>
            </div>
            <div class="marginTop10">
                <button class="ui primary button" @click="auditWithdraw">提交</button>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import tool from 'src/util/tool';
import util from '_util/index';
import logic from '_logic';
import fselect from 'components/form/select'
export default {
    props: ['id', 'option'],
    components: {
        fselect
    },
    data() {
        return {
            withdrawArray: [{
                    id: '1',
                    title: '审核提现'
                },
                {
                    id: '2',
                    title: '提交第三方'
                },
                {
                    id: '3',
                    title: '提现成功'
                },
                {
                    id: '4',
                    title: '提现失败'
                },
            ],
			loaderShow:true,
            withdrawVal: '1',
            withdrawMsg: '',
            serialNumber: '',
            returnRemark: '',
            withdrawData: {},
            withdrawList: {
                withdraw_id: {
                    name: 'ID',
                    value: ""
                },
                nick_name: {
                    name: '用户',
                    value: ""
                },
                account_name: {
                    name: '账户姓名',
                    value: ""
                },
                account_num: {
                    name: '账户账号',
                    value: ""
                },
                channel_type: {
                    name: '提现渠道',
                    value: '',
                    map: {
                        1: '支付宝'
                    }
                },
                account_type: {
                    name: '账户类型',
                    value: '',
                    map: {
                        1: '供应商',
                        2: '服务者',
                        3: 'app',
                        4: '同业者',
                        5: '服务商',
                        10: '积分账户'
                    }
                },
                money: {
                    name: '提现金额',
                    value: ""
                },
                status: {
                    name: '提现状态',
                    value: "",
                    map: {
                        1: '申请中',
                        2: '审核成功',
                        3: '提交第三方',
                        8: '提现成功',
                        10: '提现失败',
                        20: '用户账户修改'
                    }
                },
                remark: {
                    name: '备注',
                    value: ""
                },
                create_dt: {
                    name: '创建时间',
                    value: ""
                },
                update_dt: {
                    name: '更新时间',
                    value: ""
                },
            },
        }

    },
    watch: {
        id: function() {
            this.getWithdrawDetail()
        }
    },
    created() {
        this.getWithdrawDetail();
    },
    methods: {
        selectValsChange(val) {
            this.withdrawVal = val
        },
        hideMypop() {
            this.$store.state.eventVue.$emit('hideMypop')
        },
        getWithdrawDetail() {
			this.loaderShow = true;
            this.withdrawMsg = '';
            util.http.getDataCom(this, tool.getApi(this, 'Withdraw', 'withdrawDetail'), {
                id: this.id
            }, (rs) => {
				this.loaderShow = false;
                this.withdrawData = rs[0][0];
                Object.keys(this.withdrawList).forEach(item => {
                    this.withdrawList[item].value = this.withdrawData[item]
                });
            })
        },
        auditWithdraw() {
            let url = tool.getApi(this, 'Withdraw', 'withdrawAudit');
			if(this.withdrawVal==''){
				util.showMsg(this, 'error', '请选择提现状态');
				return
			}
            let parm = {
                withdraw_id: this.id,
                status: this.withdrawVal,
                remark: this.withdrawMsg
            };
            if (this.withdrawVal == 2) {
                if (this.serialNumber == '' || this.returnRemark == '') {
                    util.showMsg(this, 'error', '请填写第三方交易流水号和第三方备注信息');
					return
                }
                parm = { ...parm,
					serial_number:this.serialNumber,
					return_remark:this.returnRemark
                }
            }
            util.http.SR(this, url, parm, '操作成功', (rs) => {
                logic.list.refreshListData(this);
                this.hideMypop()
            });


        }
    }
}
</script>

<style lang="less" rel="stylesheet/less" scoped>
.withdraw-auditfc {
    margin: 0 !important;
    .row {
        .column {}
    }

}
</style>
